<script setup lang="ts">
import { ref, onMounted } from 'vue'
import { reqHasTrademark } from '@/api/product/trademark'
import type { Records,TradeMarkResponseData } from '@/api/product/trademark/type' 

const pageNo = ref<number>(1)
const limit = ref<number>(3)
const background = ref<boolean>(true) 
let trademarkList = ref<Records>([])
let total = ref<number>(0)

const getHasTrademark = async () => {
  const res:TradeMarkResponseData = await reqHasTrademark(pageNo.value, limit.value)
  if (res.code === 200) {
    trademarkList.value = res.data.records
    total.value = res.data.total
  }
}

onMounted(() => {
  getHasTrademark()//页面加载时获取品牌列表
})
</script>

<template>
  <el-card>
    <el-button type="primary" icon="Plus">添加品牌</el-button>
    <el-table style="margin:10px 0" border :data="trademarkList">
      <el-table-column type="index" label="序号" width="80px" align="center" />
      <el-table-column label="品牌名称" >
        <template #="{row}">
          <pre style="color: red;">{{ row.tmName }}</pre>
        </template>
      </el-table-column>
      <el-table-column prop="address" label="品牌LOGO" align="center" >
        <template #="{row}">
          <img style="width: 50px;height: 50px;" :src="row.logoUrl" fit="fill" :preview-src-list="[row.logoUrl]" />
        </template>
      </el-table-column>
      <el-table-column prop="address" label="品牌操作" align="center" >
        <template #="">
          <el-button type="primary" size="small">
            <el-icon>
              <Edit />
            </el-icon>
          </el-button>
          <el-button type="danger" size="small">
            <el-icon>
              <Delete />
            </el-icon>
          </el-button>
        </template>
      </el-table-column>
    </el-table>
    <el-pagination
      v-model:current-page="pageNo"
      v-model:page-size="limit"
      :page-sizes="[3, 5, 7, 9]"
      :background="background"
      layout=" prev, pager, next, jumper,->,total, sizes"
      :total="total"
      @change="getHasTrademark"
    />
  </el-card>
</template>

<style lang="scss" scoped></style>
